<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>    
<!DOCTYPE html >
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style type="text/css">
.typefont{
margin-top: 10px;
margin-bottom: 0;

}
</style>

<link href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">

<script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>

<script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>

</head>
<body>
<div class="container">
	<div class="row clearfix">
		<div class="col-md-12 column">
			<h3 class="text-center">
				增加出售商品
			</h3>
		</div>
	</div>
</div>
<div class="container">
	<div class="row clearfix">
		<div class="col-md-12 column">
				<form role="form" action="EmployeeServlet" method="get">
					<input type="hidden" name="action" value="add">
					<%
						//随机产生一个oiid
						long randomNum = System.currentTimeMillis(); 
						int temp= Math.abs((int) randomNum);
						Integer oiid = temp;
					%>
					<input type="hidden" name="oiid" value="<%= oiid.toString() %>">
					<div class="form-group">
						<label for="exampleInputPassword1">订单编号:</label><input type="text"
							class="form-control" name="oid"  value="<%=request.getParameter("oid")%>" readonly/>
					</div>
					
					<div class="form-group">
						<div class="form-group">
							<label for="exampleInputPassword1">顾客编号:</label><input type="text"
								class="form-control" name="uid" value="${requestScope.order.uid}" readonly/>
						</div>
					</div>
					<label for="exampleInputPassword1" class="typefont">名称:</label>
					<div class="form-group">
					<!-- 这里应该遍历 -->
						<select class="form-control" name="pname" id="pname">
							<c:forEach items="${requestScope.products}" var="product">
								<option value="${product.pname}">${product.pname} </option>
							</c:forEach>
						</select>
					</div>
					<div class="form-group">
					<!-- 这里应该遍历 -->
						<label for="exampleInputPassword1">价格:</label>
						<input type="text"class="form-control" name="pprice" id="pprice" readonly />
					</div>
					<div class="form-group">

						<label for="exampleInputPassword1">重量:</label>
						<input type="text" class="form-control" name="weight" id="weight"/>
					</div>
					<div class="form-group">

						<label for="exampleInputPassword1">小计:</label>
						<input type="text" class="form-control" name="tprice" id="tprice" readonly="readonly" />
					</div>
					<div class="container">
						<div class="row clearfix">
							<div class="col-md-12 column">
								<button type="submit" class="btn btn-default">提交</button>
							</div>
						</div>
					</div>
				</form>
			</div>
	</div>
</div>

</body>
<script type="text/javascript">

	$("#pname").blur(function(){
		var pname = $("#pname").val();
		//通过ajax 返回此类名称的价格
		$.ajax({          
	       	 url:"EmployeeServlet?action=returnPrice", 
	         dataType:"text",  
	         type:"post", 
	         data:{
	        	 "pname":pname
	        },
	         success:function(result){
	        	$("#pprice").val(result);
	        	
	        }, 
	        error:function(result){
	        	
	        }
	});
	})
	
	$("#weight").blur(function(){
		var pprice = new Number($("#pprice").val());
		var weight = new Number($("#weight").val());
		$("#tprice").val(pprice*weight);
	})
	
</script>











</html>